package com.juzipi.rabbit.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author juzipi
 * @Date 2021/7/30 8:27
 * @Info
 */
@Configuration
public class Demo1Config {


    public static final String demoQueue = "demo.queue";
    public static final String demoExchange = "demo.exchange";
    public static final String demo1Routing = "demo1.routing";

    /*
    创建一个sms队列和sms交换机，然后再绑定一下
     */

    @Bean
    public Queue demoQueue(){
        return new Queue(demoQueue,true);
    }

    @Bean
    public DirectExchange demoExchange(){
        return new DirectExchange(demoExchange);
    }

    @Bean
    public Binding demoBinding(){
        return BindingBuilder.bind(demoQueue()).to(demoExchange()).with(demo1Routing);
    }

}
